﻿using System;
using System.Data;
using System.Data.Objects;
using System.Data.Objects.DataClasses;
using System.Collections;
using System.ComponentModel;

using Telerik.Windows.Controls.Scheduler;
using Telerik.Windows.Controls.Scheduler.ICalendar;

using Centrica.TaskManager.Data;

namespace Centrica.TaskManager.Task.Calendar
{
    public class TaskAppointment : IAppointment
    {

        private Data.Task _task;

        public TaskAppointment(Data.Task task)
        {
            _task = task;
        }

        #region IAppointment Members

        public IAppointment Copy()
        {

            return (IAppointment)this;
        }

        public void CopyFrom(IAppointment other)
        {
            this.End = other.End;
            this.Start = other.Start;

        }

        public DateTime End
        {
            get
            {
                return _task.EndDate.GetValueOrDefault();

            }
            set
            {
                _task.EndDate  = value;
            }
        }

        public bool IsAllDayEvent
        {
            get
            {
                return false;
            }
            set
            {

            }
        }

        public RecurrenceRule RecurrenceRule
        {
            get
            {
                return null;
            }
            set
            {

            }
        }

        public event EventHandler RecurrenceRuleChanged;

        public DateTime Start
        {
            get
            {
                return _task.StartDate;
            }
            set
            {
                _task.StartDate = value;
            }
        }


        public string Subject
        {
            get
            {

                return string.IsNullOrEmpty(_task.TaskDescription) ? _task.TaskName : _task.TaskDescription;
            }
            set
            {

            }
        }

        public TimeZoneInfo TimeZone
        {
            get
            {
                return TimeZoneInfo.Local;
            }
            set
            {

            }
        }

     
        #endregion

        #region INotifyPropertyChanged Members

        public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;

        #endregion

    }
}